<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.9.1" />
<title>tronpytool.common.abi API documentation</title>
<meta name="description" content="" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>tronpytool.common.abi</code></h1>
</header>
<section id="section-intro">
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python"># --------------------------------------------------------------------
# Copyright (c) iEXBase. All rights reserved.
# Licensed under the MIT License.
# See License.txt in the project root for license information.
# --------------------------------------------------------------------

import re
from collections import (
    namedtuple,
)
from typing import Tuple

import binascii
import eth_abi
import itertools
from eth_abi import (
    encoding,
    decoding
)
from eth_abi.codec import ABICodec
from eth_abi.registry import (
    BaseEquals,
    registry as default_registry, ABIRegistry,
)
from eth_utils import to_tuple
from trx_utils import (
    decode_hex,
    is_bytes,
    is_text,
    to_text
)

from tronpytool.common.formatters import recursive_map
from tronpytool.common.toolz import (
    curry,
    partial,
    pipe,
)
from tronpytool.exceptions import FallbackNotFound

DYNAMIC_TYPES = [&#39;bytes&#39;, &#39;string&#39;]

INT_SIZES = range(8, 257, 8)
BYTES_SIZES = range(1, 33)
UINT_TYPES = [&#39;uint{0}&#39;.format(i) for i in INT_SIZES]
INT_TYPES = [&#39;int{0}&#39;.format(i) for i in INT_SIZES]
BYTES_TYPES = [&#39;bytes{0}&#39;.format(i) for i in BYTES_SIZES] + [&#39;bytes32.byte&#39;]

STATIC_TYPES = list(itertools.chain(
    [&#39;address&#39;, &#39;bool&#39;],
    UINT_TYPES,
    INT_TYPES,
    BYTES_TYPES,
))

BASE_TYPE_REGEX = &#39;|&#39;.join((
    _type + &#39;(?![a-z0-9])&#39;
    for _type
    in itertools.chain(STATIC_TYPES, DYNAMIC_TYPES)
))

SUB_TYPE_REGEX = (
    r&#39;\[&#39;
    &#39;[0-9]*&#39;
    r&#39;\]&#39;
)

TYPE_REGEX = (
    &#39;^&#39;
    &#39;(?:{base_type})&#39;
    &#39;(?:(?:{sub_type})*)?&#39;
    &#39;$&#39;
).format(
    base_type=BASE_TYPE_REGEX,
    sub_type=SUB_TYPE_REGEX,
)

NAME_REGEX = (
    &#39;[a-zA-Z_]&#39;
    &#39;[a-zA-Z0-9_]*&#39;
)

ENUM_REGEX = (
    &#39;^&#39;
    &#39;{lib_name}&#39;
    r&#39;\.&#39;
    &#39;{enum_name}&#39;
    &#39;$&#39;
).format(lib_name=NAME_REGEX, enum_name=NAME_REGEX)

END_BRACKETS_OF_ARRAY_TYPE_REGEX = r&#34;\[[^]]*\]$&#34;

NAME_REGEX = (
    &#39;[a-zA-Z_]&#39;
    &#39;[a-zA-Z0-9_]*&#39;
)

ARRAY_REGEX = (
    &#34;^&#34;
    &#34;[a-zA-Z0-9_]+&#34;
    &#34;({sub_type})+&#34;
    &#34;$&#34;
).format(sub_type=SUB_TYPE_REGEX)

RES_CODE = dict(
    SUCCESS=0,
    SIGERROR=1,
    CONTRACT_VALIDATE_ERROR=2,
    CONTRACT_EXE_ERROR=3,
    BANDWITH_ERROR=4,
    DUP_TRANSACTION_ERROR=5,
    TAPOS_ERROR=6,
    TOO_BIG_TRANSACTION_ERROR=7,
    TRANSACTION_EXPIRATION_ERROR=8,
    SERVER_BUSY=9,
    NO_CONNECTION=10,
    NOT_ENOUGH_EFFECTIVE_CONNECTION=11,
    OTHER_ERROR=20
)


def filter_by_argument_name(argument_names, contract_abi):
    return [
        abi
        for abi in contract_abi
        if set(argument_names).intersection(
            get_abi_input_names(abi)
        ) == set(argument_names)
    ]


try:
    from eth_abi.abi import (
        process_type,
        collapse_type,
    )
except ImportError:
    from eth_abi.grammar import (
        parse as parse_type_string,
        normalize as normalize_type_string,
        TupleType,
    )


    def process_type(type_str):
        normalized_type_str = normalize_type_string(type_str)
        abi_type = parse_type_string(normalized_type_str)

        if isinstance(abi_type, TupleType):
            type_str_repr = repr(type_str)
            if type_str != normalized_type_str:
                type_str_repr = &#39;{} (normalized to {})&#39;.format(
                    type_str_repr,
                    repr(normalized_type_str),
                )

            raise ValueError(
                &#34;Cannot process type {}: tuple types not supported&#34;.format(
                    type_str_repr,
                )
            )

        abi_type.validate()

        sub = abi_type.sub
        if isinstance(sub, tuple):
            sub = &#39;x&#39;.join(map(str, sub))
        elif isinstance(sub, int):
            sub = str(sub)
        else:
            sub = &#39;&#39;

        arrlist = abi_type.arrlist
        if isinstance(arrlist, tuple):
            arrlist = list(map(list, arrlist))
        else:
            arrlist = []

        return abi_type.base, sub, arrlist


    def collapse_type(base, sub, arrlist):
        return base + str(sub) + &#39;&#39;.join(map(repr, arrlist))

&#34;&#34;&#34;abi function filter processor&#34;&#34;&#34;


def filter_by_type(_type, contract_abi) -&gt; list:
    return [abi for abi in contract_abi if abi[&#39;type&#39;] == _type]


def filter_by_name(name, contract_abi) -&gt; list:
    return [
        abi
        for abi
        in contract_abi
        if (
                abi[&#39;type&#39;] not in (&#39;fallback&#39;, &#39;constructor&#39;) and
                abi[&#39;name&#39;] == name
        )
    ]


def get_abi_input_types(abi) -&gt; list:
    if &#39;inputs&#39; not in abi and abi[&#39;type&#39;] == &#39;fallback&#39;:
        return []
    else:
        return [arg[&#39;type&#39;] for arg in abi[&#39;inputs&#39;]]


def get_abi_output_types(abi) -&gt; list:
    if abi[&#39;type&#39;] == &#39;fallback&#39;:
        return []
    else:
        return [arg[&#39;type&#39;] for arg in abi[&#39;outputs&#39;]]


def get_abi_input_names(abi) -&gt; list:
    if &#39;inputs&#39; not in abi and abi[&#39;type&#39;] == &#39;fallback&#39;:
        return []
    else:
        return [arg[&#39;name&#39;] for arg in abi[&#39;inputs&#39;]]


def length_of_array_type(abi_type) -&gt; any:
    if not is_array_type(abi_type):
        raise ValueError(
            &#34;Cannot parse length of nonarray abi-type: {0}&#34;.format(abi_type)
        )

    inner_brackets = re.search(END_BRACKETS_OF_ARRAY_TYPE_REGEX, abi_type).group(0).strip(&#34;[]&#34;)
    if not inner_brackets:
        return None
    else:
        return int(inner_brackets)


def get_fallback_func_abi(contract_abi):
    fallback_abis = filter_by_type(&#39;fallback&#39;, contract_abi)
    if fallback_abis:
        return fallback_abis[0]
    else:
        raise FallbackNotFound(&#34;No fallback function was found in the contract ABI.&#34;)


def fallback_func_abi_exists(contract_abi) -&gt; list:
    return filter_by_type(&#39;fallback&#39;, contract_abi)


def get_constructor_abi(contract_abi):
    candidates = [
        abi for abi in contract_abi if abi[&#39;type&#39;] == &#39;constructor&#39;
    ]
    if len(candidates) == 1:
        return candidates[0]
    elif len(candidates) == 0:
        return None
    elif len(candidates) &gt; 1:
        raise ValueError(&#34;Found multiple constructors.&#34;)


def is_recognized_type(abi_type) -&gt; bool:
    return bool(re.match(TYPE_REGEX, abi_type))


def is_bool_type(abi_type) -&gt; bool:
    return abi_type == &#39;bool&#39;


def is_uint_type(abi_type) -&gt; bool:
    return abi_type in UINT_TYPES


def is_int_type(abi_type) -&gt; bool:
    return abi_type in INT_TYPES


def is_address_type(abi_type) -&gt; bool:
    return abi_type == &#39;address&#39;


def is_bytes_type(abi_type) -&gt; bool:
    return abi_type in BYTES_TYPES + [&#39;bytes&#39;]


def is_string_type(abi_type) -&gt; bool:
    return abi_type == &#39;string&#39;


@curry
def is_length(target_length, value) -&gt; bool:
    return len(value) == target_length


def size_of_type(abi_type):
    &#34;&#34;&#34;
    Returns size in bits of abi_type
    &#34;&#34;&#34;
    if &#39;string&#39; in abi_type:
        return None
    if &#39;byte&#39; in abi_type:
        return None
    if &#39;[&#39; in abi_type:
        return None
    if abi_type == &#39;bool&#39;:
        return 8
    if abi_type == &#39;address&#39;:
        return 160
    return int(re.sub(r&#34;\D&#34;, &#34;&#34;, abi_type))


def is_array_type(abi_type) -&gt; bool:
    return bool(re.match(ARRAY_REGEX, abi_type))


def sub_type_of_array_type(abi_type):
    if not is_array_type(abi_type):
        raise ValueError(
            &#34;Cannot parse subtype of nonarray abi-type: {0}&#34;.format(abi_type)
        )

    return re.sub(END_BRACKETS_OF_ARRAY_TYPE_REGEX, &#39;&#39;, abi_type, 1)


def is_probably_enum(abi_type):
    return bool(re.match(ENUM_REGEX, abi_type))


@to_tuple
def normalize_event_input_types(abi_args):
    for arg in abi_args:
        if is_recognized_type(arg[&#39;type&#39;]):
            yield arg
        elif is_probably_enum(arg[&#39;type&#39;]):
            yield {k: &#39;uint8&#39; if k == &#39;type&#39; else v for k, v in arg.items()}
        else:
            yield arg


def abi_to_signature(abi):
    function_signature = &#34;{fn_name}({fn_input_types})&#34;.format(
        fn_name=abi[&#39;name&#39;],
        fn_input_types=&#39;,&#39;.join([
            arg[&#39;type&#39;] for arg in normalize_event_input_types(abi.get(&#39;inputs&#39;, []))
        ]),
    )
    return function_signature


def filter_by_argument_count(num_arguments, contract_abi) -&gt; list:
    return [
        abi
        for abi
        in contract_abi
        if len(abi[&#39;inputs&#39;]) == num_arguments
    ]


def filter_by_encodability(args, kwargs, contract_abi) -&gt; list:
    return [
        function_abi
        for function_abi
        in contract_abi
        if check_if_arguments_can_be_encoded(function_abi, args, kwargs)
    ]


class AcceptsHexStrMixin:
    def validate_value(self, value):
        if is_text(value):
            try:
                value = decode_hex(value)
            except binascii.Error:
                self.invalidate_value(
                    value,
                    msg=&#39;invalid hex string&#39;,
                )

        super().validate_value(value)


from eth_abi.base import parse_type_str
from eth_abi.decoding import Fixed32ByteSizeDecoder
from eth_abi.encoding import Fixed32ByteSizeEncoder

from tronpytool.common.key import to_base58check_address, is_address, to_tvm_address


class TronAddressDecoder(Fixed32ByteSizeDecoder):
    value_bit_size = 20 * 8
    is_big_endian = True
    decoder_fn = staticmethod(to_base58check_address)

    @parse_type_str(&#34;address&#34;)
    def from_type_str(cls, abi_type, registry):
        return cls()


class TronAddressEncoder(Fixed32ByteSizeEncoder):
    value_bit_size = 20 * 8
    encode_fn = staticmethod(to_tvm_address)
    is_big_endian = True

    @classmethod
    def validate_value(cls, value):
        if not is_address(value):
            cls.invalidate_value(value)

    def validate(self):
        super().validate()

        if self.value_bit_size != 20 * 8:
            raise ValueError(&#34;Addresses must be 160 bits in length&#34;)

    @parse_type_str(&#34;address&#34;)
    def from_type_str(cls, abi_type, registry):
        return cls()


# interface
class ByteStringEncoder(AcceptsHexStrMixin, encoding.ByteStringEncoder):
    pass


# interface
class BytesEncoder(AcceptsHexStrMixin, encoding.BytesEncoder):
    pass


class TextStringEncoder(encoding.TextStringEncoder):
    @classmethod
    def validate_value(cls, value):
        if is_bytes(value):
            try:
                value = to_text(value)
            except UnicodeDecodeError:
                cls.invalidate_value(
                    value,
                    msg=&#39;not decodable as unicode string&#39;,
                )

        super().validate_value(value)


def check_if_arguments_can_be_encoded(function_abi, args, kwargs):
    try:
        arguments = merge_args_and_kwargs(function_abi, args, kwargs)
    except TypeError:
        return False

    if len(function_abi.get(&#39;inputs&#39;, [])) != len(arguments):
        return False

    types = get_abi_input_types(function_abi)

    return all(
        is_encodable(_type, arg)
        for _type, arg in zip(types, arguments)
    )


def merge_args_and_kwargs(function_abi, args, kwargs):
    if len(args) + len(kwargs) != len(function_abi.get(&#39;inputs&#39;, [])):
        raise TypeError(
            &#34;Incorrect argument count.  Expected &#39;{0}&#39;.  Got &#39;{1}&#39;&#34;.format(
                len(function_abi[&#39;inputs&#39;]),
                len(args) + len(kwargs),
            )
        )

    if not kwargs:
        return args

    args_as_kwargs = {
        arg_abi[&#39;name&#39;]: arg
        for arg_abi, arg in zip(function_abi[&#39;inputs&#39;], args)
    }
    duplicate_keys = set(args_as_kwargs).intersection(kwargs.keys())
    if duplicate_keys:
        raise TypeError(
            &#34;{fn_name}() got multiple values for argument(s) &#39;{dups}&#39;&#34;.format(
                fn_name=function_abi[&#39;name&#39;],
                dups=&#39;, &#39;.join(duplicate_keys),
            )
        )

    sorted_arg_names = [arg_abi[&#39;name&#39;] for arg_abi in function_abi[&#39;inputs&#39;]]

    unknown_kwargs = {key for key in kwargs.keys() if key not in sorted_arg_names}
    if unknown_kwargs:
        if function_abi.get(&#39;name&#39;):
            raise TypeError(
                &#34;{fn_name}() got unexpected keyword argument(s) &#39;{dups}&#39;&#34;.format(
                    fn_name=function_abi.get(&#39;name&#39;),
                    dups=&#39;, &#39;.join(unknown_kwargs),
                )
            )
        # show type instead of name in the error message incase key &#39;name&#39; is missing.
        raise TypeError(
            &#34;Type: &#39;{_type}&#39; got unexpected keyword argument(s) &#39;{dups}&#39;&#34;.format(
                _type=function_abi.get(&#39;type&#39;),
                dups=&#39;, &#39;.join(unknown_kwargs),
            )
        )

    sorted_args = list(zip(
        *sorted(
            itertools.chain(kwargs.items(), args_as_kwargs.items()),
            key=lambda kv: sorted_arg_names.index(kv[0])
        )
    ))
    if sorted_args:
        return sorted_args[1]
    else:
        return tuple()


def abi_sub_tree(data_type, data_value):
    if data_type is None:
        return ABITypedData([None, data_value])

    try:
        base, sub, arrlist = data_type
    except ValueError:
        base, sub, arrlist = process_type(data_type)

    collapsed = collapse_type(base, sub, arrlist)

    if arrlist:
        sub_type = (base, sub, arrlist[:-1])
        return ABITypedData([
            collapsed,
            [
                abi_sub_tree(sub_type, sub_value)
                for sub_value in data_value
            ],
        ])
    else:
        return ABITypedData([collapsed, data_value])


@curry
def map_abi_data(normalizers, types, data):
    &#34;&#34;&#34;
        This function will apply normalizers to your data, in the
    context of the relevant types. Each normalizer is in the format:

    def normalizer(datatype, data):
        # Conditionally modify data
        return (datatype, data)

    Where datatype is a valid ABI type string, like &#34;uint&#34;.

    In case of an array, like &#34;bool[2]&#34;, normalizer will receive `data`
    as an iterable of typed data, like `[(&#34;bool&#34;, True), (&#34;bool&#34;, False)]`.

    Internals
    ---

    This is accomplished by:

    1. Decorating the data tree with types
    2. Recursively mapping each of the normalizers to the data
    3. Stripping the types back out of the tree
    &#34;&#34;&#34;

    pipeline = itertools.chain(
        [abi_data_tree(types)],
        map(data_tree_map, normalizers),
        [partial(recursive_map, strip_abi_type)],
    )

    return pipe(data, *pipeline)


@curry
def abi_data_tree(types, data) -&gt; list:
    &#34;&#34;&#34;Decorate the data tree with pairs of (type, data). The pair tuple is actually an
    ABITypedData, but can be accessed as a tuple.

    Examples:
        &gt;&gt;&gt; abi_data_tree(types=[&#34;bool[2]&#34;, &#34;uint&#34;], data=[[True, False], 0])

    Returns:
        [(&#34;bool[2]&#34;, [(&#34;bool&#34;, True), (&#34;bool&#34;, False)]), (&#34;uint256&#34;, 0)]
    &#34;&#34;&#34;

    return [
        abi_sub_tree(data_type, data_value)
        for data_type, data_value
        in zip(types, data)
    ]


@curry
def data_tree_map(func, data_tree):
    &#34;&#34;&#34;
    Map func to every ABITypedData element in the tree. func will
    receive two args: abi_type, and data
    &#34;&#34;&#34;

    def map_to_typed_data(elements):
        if isinstance(elements, ABITypedData) and elements.abi_type is not None:
            return ABITypedData(func(*elements))
        else:
            return elements

    return recursive_map(map_to_typed_data, data_tree)


class ABITypedData(namedtuple(&#39;ABITypedData&#39;, &#39;abi_type, data&#39;)):
    &#34;&#34;&#34;
    This class marks data as having a certain ABI-type.

    &gt;&gt;&gt; a1 = ABITypedData([&#39;address&#39;, addr1])
    &gt;&gt;&gt; a2 = ABITypedData([&#39;address&#39;, addr2])
    &gt;&gt;&gt; addrs = ABITypedData([&#39;address[]&#39;, [a1, a2])

    You can access the fields using tuple() interface, or with
    attributes:

    &gt;&gt;&gt; assert a1.abi_type == a1[0]
    &gt;&gt;&gt; assert a1.data == a1[1]

    Unlike a typical `namedtuple`, you initialize with a single
    positional argument that is iterable, to match the init
    interface of all other relevant collections.
    &#34;&#34;&#34;

    def __new__(cls, iterable):
        return super().__new__(cls, *iterable)


def strip_abi_type(elements):
    if isinstance(elements, ABITypedData):
        return elements.data
    else:
        return elements


def method_result_handler(r: dict) -&gt; Tuple[bool, str, str]:
    if &#34;result&#34; in r[&#34;result&#34;]:
        transID = r[&#34;transaction&#34;][&#34;txID&#34;]
        resultcode = r[&#34;result&#34;][&#34;result&#34;]
        if resultcode:
            if &#34;constant_result&#34; in r:
                return True, r[&#34;constant_result&#34;], transID
            else:
                return True, &#34;&#34;, transID
        else:
            print(&#34;======&#34;)
            print(r)
            print(&#34;======&#34;)
            return True, &#34;&#34;, &#34;&#34;

    elif &#34;code&#34; in r[&#34;result&#34;]:
        resultcode = r[&#34;result&#34;][&#34;code&#34;]
        if RES_CODE.get(resultcode) &gt; 0:
            return False, resultcode, r[&#34;result&#34;][&#34;message&#34;]
        else:
            return True, resultcode, r[&#34;result&#34;][&#34;message&#34;]


# We make a copy here just to make sure that eth-abi&#39;s default registry is not
# affected by our custom encoder subclasses
registry = default_registry.copy()


def tron_patch_ethereum_types(_registry: ABIRegistry):
    _registry.register(
        BaseEquals(&#39;address&#39;),
        TronAddressEncoder,
        TronAddressDecoder,
        label=&#39;address&#39;,
    )

    _registry.register(
        BaseEquals(&#39;trcToken&#39;),
        eth_abi.encoding.UnsignedIntegerEncoder,
        eth_abi.decoding.UnsignedIntegerDecoder,
        label=&#39;trcToken&#39;,
    )

    _registry.register(
        BaseEquals(&#39;trc20&#39;),
        eth_abi.encoding.UnsignedIntegerEncoder,
        eth_abi.decoding.UnsignedIntegerDecoder,
        label=&#39;trc20&#39;,
    )

    _registry.register(
        BaseEquals(&#39;bytes&#39;, with_sub=True),
        BytesEncoder,
        decoding.BytesDecoder,
        label=&#39;bytes&lt;M&gt;&#39;,
    )

    _registry.register(
        BaseEquals(&#39;bytes&#39;, with_sub=False),
        ByteStringEncoder,
        decoding.ByteStringDecoder,
        label=&#39;bytes&#39;,
    )

    _registry.register(
        BaseEquals(&#39;string&#39;),
        TextStringEncoder,
        decoding.StringDecoder,
        label=&#39;string&#39;,
    )


registry.unregister(&#39;address&#39;)
registry.unregister(&#39;bytes&lt;M&gt;&#39;)
registry.unregister(&#39;bytes&#39;)
registry.unregister(&#39;string&#39;)
tron_patch_ethereum_types(registry)
_codec = ABICodec(registry)
encode_abi = _codec.encode_abi
encode_single = _codec.encode_single
decode_abi = _codec.decode_abi
decode_single = _codec.decode_single
is_encodable = _codec.is_encodable
is_encodable_type = _codec.is_encodable_type</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="tronpytool.common.abi.abi_data_tree"><code class="name flex">
<span>def <span class="ident">abi_data_tree</span></span>(<span>types='__no__default__', data='__no__default__') ‑> list</span>
</code></dt>
<dd>
<div class="desc"><p>Decorate the data tree with pairs of (type, data). The pair tuple is actually an
ABITypedData, but can be accessed as a tuple.</p>
<h2 id="examples">Examples</h2>
<pre><code class="python-repl">&gt;&gt;&gt; abi_data_tree(types=[&quot;bool[2]&quot;, &quot;uint&quot;], data=[[True, False], 0])
</code></pre>
<h2 id="returns">Returns</h2>
<p>[("bool[2]", [("bool", True), ("bool", False)]), ("uint256", 0)]</p></div>
</dd>
<dt id="tronpytool.common.abi.abi_sub_tree"><code class="name flex">
<span>def <span class="ident">abi_sub_tree</span></span>(<span>data_type, data_value)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def abi_sub_tree(data_type, data_value):
    if data_type is None:
        return ABITypedData([None, data_value])

    try:
        base, sub, arrlist = data_type
    except ValueError:
        base, sub, arrlist = process_type(data_type)

    collapsed = collapse_type(base, sub, arrlist)

    if arrlist:
        sub_type = (base, sub, arrlist[:-1])
        return ABITypedData([
            collapsed,
            [
                abi_sub_tree(sub_type, sub_value)
                for sub_value in data_value
            ],
        ])
    else:
        return ABITypedData([collapsed, data_value])</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.abi_to_signature"><code class="name flex">
<span>def <span class="ident">abi_to_signature</span></span>(<span>abi)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def abi_to_signature(abi):
    function_signature = &#34;{fn_name}({fn_input_types})&#34;.format(
        fn_name=abi[&#39;name&#39;],
        fn_input_types=&#39;,&#39;.join([
            arg[&#39;type&#39;] for arg in normalize_event_input_types(abi.get(&#39;inputs&#39;, []))
        ]),
    )
    return function_signature</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.check_if_arguments_can_be_encoded"><code class="name flex">
<span>def <span class="ident">check_if_arguments_can_be_encoded</span></span>(<span>function_abi, args, kwargs)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def check_if_arguments_can_be_encoded(function_abi, args, kwargs):
    try:
        arguments = merge_args_and_kwargs(function_abi, args, kwargs)
    except TypeError:
        return False

    if len(function_abi.get(&#39;inputs&#39;, [])) != len(arguments):
        return False

    types = get_abi_input_types(function_abi)

    return all(
        is_encodable(_type, arg)
        for _type, arg in zip(types, arguments)
    )</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.collapse_type"><code class="name flex">
<span>def <span class="ident">collapse_type</span></span>(<span>base, sub, arrlist)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def collapse_type(base, sub, arrlist):
    return base + str(sub) + &#39;&#39;.join(map(repr, arrlist))</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.data_tree_map"><code class="name flex">
<span>def <span class="ident">data_tree_map</span></span>(<span>func='__no__default__', data_tree='__no__default__')</span>
</code></dt>
<dd>
<div class="desc"><p>Map func to every ABITypedData element in the tree. func will
receive two args: abi_type, and data</p></div>
</dd>
<dt id="tronpytool.common.abi.fallback_func_abi_exists"><code class="name flex">
<span>def <span class="ident">fallback_func_abi_exists</span></span>(<span>contract_abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def fallback_func_abi_exists(contract_abi) -&gt; list:
    return filter_by_type(&#39;fallback&#39;, contract_abi)</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.filter_by_argument_count"><code class="name flex">
<span>def <span class="ident">filter_by_argument_count</span></span>(<span>num_arguments, contract_abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def filter_by_argument_count(num_arguments, contract_abi) -&gt; list:
    return [
        abi
        for abi
        in contract_abi
        if len(abi[&#39;inputs&#39;]) == num_arguments
    ]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.filter_by_argument_name"><code class="name flex">
<span>def <span class="ident">filter_by_argument_name</span></span>(<span>argument_names, contract_abi)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def filter_by_argument_name(argument_names, contract_abi):
    return [
        abi
        for abi in contract_abi
        if set(argument_names).intersection(
            get_abi_input_names(abi)
        ) == set(argument_names)
    ]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.filter_by_encodability"><code class="name flex">
<span>def <span class="ident">filter_by_encodability</span></span>(<span>args, kwargs, contract_abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def filter_by_encodability(args, kwargs, contract_abi) -&gt; list:
    return [
        function_abi
        for function_abi
        in contract_abi
        if check_if_arguments_can_be_encoded(function_abi, args, kwargs)
    ]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.filter_by_name"><code class="name flex">
<span>def <span class="ident">filter_by_name</span></span>(<span>name, contract_abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def filter_by_name(name, contract_abi) -&gt; list:
    return [
        abi
        for abi
        in contract_abi
        if (
                abi[&#39;type&#39;] not in (&#39;fallback&#39;, &#39;constructor&#39;) and
                abi[&#39;name&#39;] == name
        )
    ]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.filter_by_type"><code class="name flex">
<span>def <span class="ident">filter_by_type</span></span>(<span>_type, contract_abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def filter_by_type(_type, contract_abi) -&gt; list:
    return [abi for abi in contract_abi if abi[&#39;type&#39;] == _type]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.get_abi_input_names"><code class="name flex">
<span>def <span class="ident">get_abi_input_names</span></span>(<span>abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_abi_input_names(abi) -&gt; list:
    if &#39;inputs&#39; not in abi and abi[&#39;type&#39;] == &#39;fallback&#39;:
        return []
    else:
        return [arg[&#39;name&#39;] for arg in abi[&#39;inputs&#39;]]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.get_abi_input_types"><code class="name flex">
<span>def <span class="ident">get_abi_input_types</span></span>(<span>abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_abi_input_types(abi) -&gt; list:
    if &#39;inputs&#39; not in abi and abi[&#39;type&#39;] == &#39;fallback&#39;:
        return []
    else:
        return [arg[&#39;type&#39;] for arg in abi[&#39;inputs&#39;]]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.get_abi_output_types"><code class="name flex">
<span>def <span class="ident">get_abi_output_types</span></span>(<span>abi) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_abi_output_types(abi) -&gt; list:
    if abi[&#39;type&#39;] == &#39;fallback&#39;:
        return []
    else:
        return [arg[&#39;type&#39;] for arg in abi[&#39;outputs&#39;]]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.get_constructor_abi"><code class="name flex">
<span>def <span class="ident">get_constructor_abi</span></span>(<span>contract_abi)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_constructor_abi(contract_abi):
    candidates = [
        abi for abi in contract_abi if abi[&#39;type&#39;] == &#39;constructor&#39;
    ]
    if len(candidates) == 1:
        return candidates[0]
    elif len(candidates) == 0:
        return None
    elif len(candidates) &gt; 1:
        raise ValueError(&#34;Found multiple constructors.&#34;)</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.get_fallback_func_abi"><code class="name flex">
<span>def <span class="ident">get_fallback_func_abi</span></span>(<span>contract_abi)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_fallback_func_abi(contract_abi):
    fallback_abis = filter_by_type(&#39;fallback&#39;, contract_abi)
    if fallback_abis:
        return fallback_abis[0]
    else:
        raise FallbackNotFound(&#34;No fallback function was found in the contract ABI.&#34;)</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_address_type"><code class="name flex">
<span>def <span class="ident">is_address_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_address_type(abi_type) -&gt; bool:
    return abi_type == &#39;address&#39;</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_array_type"><code class="name flex">
<span>def <span class="ident">is_array_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_array_type(abi_type) -&gt; bool:
    return bool(re.match(ARRAY_REGEX, abi_type))</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_bool_type"><code class="name flex">
<span>def <span class="ident">is_bool_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_bool_type(abi_type) -&gt; bool:
    return abi_type == &#39;bool&#39;</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_bytes_type"><code class="name flex">
<span>def <span class="ident">is_bytes_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_bytes_type(abi_type) -&gt; bool:
    return abi_type in BYTES_TYPES + [&#39;bytes&#39;]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_int_type"><code class="name flex">
<span>def <span class="ident">is_int_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_int_type(abi_type) -&gt; bool:
    return abi_type in INT_TYPES</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_length"><code class="name flex">
<span>def <span class="ident">is_length</span></span>(<span>target_length='__no__default__', value='__no__default__') ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.common.abi.is_probably_enum"><code class="name flex">
<span>def <span class="ident">is_probably_enum</span></span>(<span>abi_type)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_probably_enum(abi_type):
    return bool(re.match(ENUM_REGEX, abi_type))</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_recognized_type"><code class="name flex">
<span>def <span class="ident">is_recognized_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_recognized_type(abi_type) -&gt; bool:
    return bool(re.match(TYPE_REGEX, abi_type))</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_string_type"><code class="name flex">
<span>def <span class="ident">is_string_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_string_type(abi_type) -&gt; bool:
    return abi_type == &#39;string&#39;</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.is_uint_type"><code class="name flex">
<span>def <span class="ident">is_uint_type</span></span>(<span>abi_type) ‑> bool</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_uint_type(abi_type) -&gt; bool:
    return abi_type in UINT_TYPES</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.length_of_array_type"><code class="name flex">
<span>def <span class="ident">length_of_array_type</span></span>(<span>abi_type) ‑> <built-in function any></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def length_of_array_type(abi_type) -&gt; any:
    if not is_array_type(abi_type):
        raise ValueError(
            &#34;Cannot parse length of nonarray abi-type: {0}&#34;.format(abi_type)
        )

    inner_brackets = re.search(END_BRACKETS_OF_ARRAY_TYPE_REGEX, abi_type).group(0).strip(&#34;[]&#34;)
    if not inner_brackets:
        return None
    else:
        return int(inner_brackets)</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.map_abi_data"><code class="name flex">
<span>def <span class="ident">map_abi_data</span></span>(<span>normalizers='__no__default__', types='__no__default__', data='__no__default__')</span>
</code></dt>
<dd>
<div class="desc"><p>This function will apply normalizers to your data, in the
context of the relevant types. Each normalizer is in the format:</p>
<p>def normalizer(datatype, data):
# Conditionally modify data
return (datatype, data)</p>
<p>Where datatype is a valid ABI type string, like "uint".</p>
<p>In case of an array, like "bool[2]", normalizer will receive <code>data</code>
as an iterable of typed data, like <code>[("bool", True), ("bool", False)]</code>.</p>
<h2 id="internals">Internals</h2>
<p>This is accomplished by:</p>
<ol>
<li>Decorating the data tree with types</li>
<li>Recursively mapping each of the normalizers to the data</li>
<li>Stripping the types back out of the tree</li>
</ol></div>
</dd>
<dt id="tronpytool.common.abi.merge_args_and_kwargs"><code class="name flex">
<span>def <span class="ident">merge_args_and_kwargs</span></span>(<span>function_abi, args, kwargs)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def merge_args_and_kwargs(function_abi, args, kwargs):
    if len(args) + len(kwargs) != len(function_abi.get(&#39;inputs&#39;, [])):
        raise TypeError(
            &#34;Incorrect argument count.  Expected &#39;{0}&#39;.  Got &#39;{1}&#39;&#34;.format(
                len(function_abi[&#39;inputs&#39;]),
                len(args) + len(kwargs),
            )
        )

    if not kwargs:
        return args

    args_as_kwargs = {
        arg_abi[&#39;name&#39;]: arg
        for arg_abi, arg in zip(function_abi[&#39;inputs&#39;], args)
    }
    duplicate_keys = set(args_as_kwargs).intersection(kwargs.keys())
    if duplicate_keys:
        raise TypeError(
            &#34;{fn_name}() got multiple values for argument(s) &#39;{dups}&#39;&#34;.format(
                fn_name=function_abi[&#39;name&#39;],
                dups=&#39;, &#39;.join(duplicate_keys),
            )
        )

    sorted_arg_names = [arg_abi[&#39;name&#39;] for arg_abi in function_abi[&#39;inputs&#39;]]

    unknown_kwargs = {key for key in kwargs.keys() if key not in sorted_arg_names}
    if unknown_kwargs:
        if function_abi.get(&#39;name&#39;):
            raise TypeError(
                &#34;{fn_name}() got unexpected keyword argument(s) &#39;{dups}&#39;&#34;.format(
                    fn_name=function_abi.get(&#39;name&#39;),
                    dups=&#39;, &#39;.join(unknown_kwargs),
                )
            )
        # show type instead of name in the error message incase key &#39;name&#39; is missing.
        raise TypeError(
            &#34;Type: &#39;{_type}&#39; got unexpected keyword argument(s) &#39;{dups}&#39;&#34;.format(
                _type=function_abi.get(&#39;type&#39;),
                dups=&#39;, &#39;.join(unknown_kwargs),
            )
        )

    sorted_args = list(zip(
        *sorted(
            itertools.chain(kwargs.items(), args_as_kwargs.items()),
            key=lambda kv: sorted_arg_names.index(kv[0])
        )
    ))
    if sorted_args:
        return sorted_args[1]
    else:
        return tuple()</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.method_result_handler"><code class="name flex">
<span>def <span class="ident">method_result_handler</span></span>(<span>r: dict) ‑> Tuple[bool, str, str]</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def method_result_handler(r: dict) -&gt; Tuple[bool, str, str]:
    if &#34;result&#34; in r[&#34;result&#34;]:
        transID = r[&#34;transaction&#34;][&#34;txID&#34;]
        resultcode = r[&#34;result&#34;][&#34;result&#34;]
        if resultcode:
            if &#34;constant_result&#34; in r:
                return True, r[&#34;constant_result&#34;], transID
            else:
                return True, &#34;&#34;, transID
        else:
            print(&#34;======&#34;)
            print(r)
            print(&#34;======&#34;)
            return True, &#34;&#34;, &#34;&#34;

    elif &#34;code&#34; in r[&#34;result&#34;]:
        resultcode = r[&#34;result&#34;][&#34;code&#34;]
        if RES_CODE.get(resultcode) &gt; 0:
            return False, resultcode, r[&#34;result&#34;][&#34;message&#34;]
        else:
            return True, resultcode, r[&#34;result&#34;][&#34;message&#34;]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.normalize_event_input_types"><code class="name flex">
<span>def <span class="ident">normalize_event_input_types</span></span>(<span>abi_args)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@to_tuple
def normalize_event_input_types(abi_args):
    for arg in abi_args:
        if is_recognized_type(arg[&#39;type&#39;]):
            yield arg
        elif is_probably_enum(arg[&#39;type&#39;]):
            yield {k: &#39;uint8&#39; if k == &#39;type&#39; else v for k, v in arg.items()}
        else:
            yield arg</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.process_type"><code class="name flex">
<span>def <span class="ident">process_type</span></span>(<span>type_str)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def process_type(type_str):
    normalized_type_str = normalize_type_string(type_str)
    abi_type = parse_type_string(normalized_type_str)

    if isinstance(abi_type, TupleType):
        type_str_repr = repr(type_str)
        if type_str != normalized_type_str:
            type_str_repr = &#39;{} (normalized to {})&#39;.format(
                type_str_repr,
                repr(normalized_type_str),
            )

        raise ValueError(
            &#34;Cannot process type {}: tuple types not supported&#34;.format(
                type_str_repr,
            )
        )

    abi_type.validate()

    sub = abi_type.sub
    if isinstance(sub, tuple):
        sub = &#39;x&#39;.join(map(str, sub))
    elif isinstance(sub, int):
        sub = str(sub)
    else:
        sub = &#39;&#39;

    arrlist = abi_type.arrlist
    if isinstance(arrlist, tuple):
        arrlist = list(map(list, arrlist))
    else:
        arrlist = []

    return abi_type.base, sub, arrlist</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.size_of_type"><code class="name flex">
<span>def <span class="ident">size_of_type</span></span>(<span>abi_type)</span>
</code></dt>
<dd>
<div class="desc"><p>Returns size in bits of abi_type</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def size_of_type(abi_type):
    &#34;&#34;&#34;
    Returns size in bits of abi_type
    &#34;&#34;&#34;
    if &#39;string&#39; in abi_type:
        return None
    if &#39;byte&#39; in abi_type:
        return None
    if &#39;[&#39; in abi_type:
        return None
    if abi_type == &#39;bool&#39;:
        return 8
    if abi_type == &#39;address&#39;:
        return 160
    return int(re.sub(r&#34;\D&#34;, &#34;&#34;, abi_type))</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.strip_abi_type"><code class="name flex">
<span>def <span class="ident">strip_abi_type</span></span>(<span>elements)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def strip_abi_type(elements):
    if isinstance(elements, ABITypedData):
        return elements.data
    else:
        return elements</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.sub_type_of_array_type"><code class="name flex">
<span>def <span class="ident">sub_type_of_array_type</span></span>(<span>abi_type)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def sub_type_of_array_type(abi_type):
    if not is_array_type(abi_type):
        raise ValueError(
            &#34;Cannot parse subtype of nonarray abi-type: {0}&#34;.format(abi_type)
        )

    return re.sub(END_BRACKETS_OF_ARRAY_TYPE_REGEX, &#39;&#39;, abi_type, 1)</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.tron_patch_ethereum_types"><code class="name flex">
<span>def <span class="ident">tron_patch_ethereum_types</span></span>(<span>_registry: eth_abi.registry.ABIRegistry)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def tron_patch_ethereum_types(_registry: ABIRegistry):
    _registry.register(
        BaseEquals(&#39;address&#39;),
        TronAddressEncoder,
        TronAddressDecoder,
        label=&#39;address&#39;,
    )

    _registry.register(
        BaseEquals(&#39;trcToken&#39;),
        eth_abi.encoding.UnsignedIntegerEncoder,
        eth_abi.decoding.UnsignedIntegerDecoder,
        label=&#39;trcToken&#39;,
    )

    _registry.register(
        BaseEquals(&#39;trc20&#39;),
        eth_abi.encoding.UnsignedIntegerEncoder,
        eth_abi.decoding.UnsignedIntegerDecoder,
        label=&#39;trc20&#39;,
    )

    _registry.register(
        BaseEquals(&#39;bytes&#39;, with_sub=True),
        BytesEncoder,
        decoding.BytesDecoder,
        label=&#39;bytes&lt;M&gt;&#39;,
    )

    _registry.register(
        BaseEquals(&#39;bytes&#39;, with_sub=False),
        ByteStringEncoder,
        decoding.ByteStringDecoder,
        label=&#39;bytes&#39;,
    )

    _registry.register(
        BaseEquals(&#39;string&#39;),
        TextStringEncoder,
        decoding.StringDecoder,
        label=&#39;string&#39;,
    )</code></pre>
</details>
</dd>
</dl>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="tronpytool.common.abi.ABITypedData"><code class="flex name class">
<span>class <span class="ident">ABITypedData</span></span>
<span>(</span><span>iterable)</span>
</code></dt>
<dd>
<div class="desc"><p>This class marks data as having a certain ABI-type.</p>
<pre><code class="python-repl">&gt;&gt;&gt; a1 = ABITypedData(['address', addr1])
&gt;&gt;&gt; a2 = ABITypedData(['address', addr2])
&gt;&gt;&gt; addrs = ABITypedData(['address[]', [a1, a2])
</code></pre>
<p>You can access the fields using tuple() interface, or with
attributes:</p>
<pre><code class="python-repl">&gt;&gt;&gt; assert a1.abi_type == a1[0]
&gt;&gt;&gt; assert a1.data == a1[1]
</code></pre>
<p>Unlike a typical <code>namedtuple</code>, you initialize with a single
positional argument that is iterable, to match the init
interface of all other relevant collections.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ABITypedData(namedtuple(&#39;ABITypedData&#39;, &#39;abi_type, data&#39;)):
    &#34;&#34;&#34;
    This class marks data as having a certain ABI-type.

    &gt;&gt;&gt; a1 = ABITypedData([&#39;address&#39;, addr1])
    &gt;&gt;&gt; a2 = ABITypedData([&#39;address&#39;, addr2])
    &gt;&gt;&gt; addrs = ABITypedData([&#39;address[]&#39;, [a1, a2])

    You can access the fields using tuple() interface, or with
    attributes:

    &gt;&gt;&gt; assert a1.abi_type == a1[0]
    &gt;&gt;&gt; assert a1.data == a1[1]

    Unlike a typical `namedtuple`, you initialize with a single
    positional argument that is iterable, to match the init
    interface of all other relevant collections.
    &#34;&#34;&#34;

    def __new__(cls, iterable):
        return super().__new__(cls, *iterable)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li>builtins.tuple</li>
</ul>
</dd>
<dt id="tronpytool.common.abi.AcceptsHexStrMixin"><code class="flex name class">
<span>class <span class="ident">AcceptsHexStrMixin</span></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class AcceptsHexStrMixin:
    def validate_value(self, value):
        if is_text(value):
            try:
                value = decode_hex(value)
            except binascii.Error:
                self.invalidate_value(
                    value,
                    msg=&#39;invalid hex string&#39;,
                )

        super().validate_value(value)</code></pre>
</details>
<h3>Subclasses</h3>
<ul class="hlist">
<li><a title="tronpytool.common.abi.ByteStringEncoder" href="#tronpytool.common.abi.ByteStringEncoder">ByteStringEncoder</a></li>
<li><a title="tronpytool.common.abi.BytesEncoder" href="#tronpytool.common.abi.BytesEncoder">BytesEncoder</a></li>
</ul>
<h3>Methods</h3>
<dl>
<dt id="tronpytool.common.abi.AcceptsHexStrMixin.validate_value"><code class="name flex">
<span>def <span class="ident">validate_value</span></span>(<span>self, value)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def validate_value(self, value):
    if is_text(value):
        try:
            value = decode_hex(value)
        except binascii.Error:
            self.invalidate_value(
                value,
                msg=&#39;invalid hex string&#39;,
            )

    super().validate_value(value)</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.common.abi.ByteStringEncoder"><code class="flex name class">
<span>class <span class="ident">ByteStringEncoder</span></span>
<span>(</span><span>**kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Base class for all encoder classes.
Subclass this if you want to define a
custom encoder class.
Subclasses must also implement
:any:<code>BaseCoder.from_type_str</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ByteStringEncoder(AcceptsHexStrMixin, encoding.ByteStringEncoder):
    pass</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="tronpytool.common.abi.AcceptsHexStrMixin" href="#tronpytool.common.abi.AcceptsHexStrMixin">AcceptsHexStrMixin</a></li>
<li>eth_abi.encoding.ByteStringEncoder</li>
<li>eth_abi.encoding.BaseEncoder</li>
<li>eth_abi.base.BaseCoder</li>
</ul>
</dd>
<dt id="tronpytool.common.abi.BytesEncoder"><code class="flex name class">
<span>class <span class="ident">BytesEncoder</span></span>
<span>(</span><span>**kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Base class for all encoder classes.
Subclass this if you want to define a
custom encoder class.
Subclasses must also implement
:any:<code>BaseCoder.from_type_str</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class BytesEncoder(AcceptsHexStrMixin, encoding.BytesEncoder):
    pass</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="tronpytool.common.abi.AcceptsHexStrMixin" href="#tronpytool.common.abi.AcceptsHexStrMixin">AcceptsHexStrMixin</a></li>
<li>eth_abi.encoding.BytesEncoder</li>
<li>eth_abi.encoding.Fixed32ByteSizeEncoder</li>
<li>eth_abi.encoding.FixedSizeEncoder</li>
<li>eth_abi.encoding.BaseEncoder</li>
<li>eth_abi.base.BaseCoder</li>
</ul>
</dd>
<dt id="tronpytool.common.abi.TextStringEncoder"><code class="flex name class">
<span>class <span class="ident">TextStringEncoder</span></span>
<span>(</span><span>**kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Base class for all encoder classes.
Subclass this if you want to define a
custom encoder class.
Subclasses must also implement
:any:<code>BaseCoder.from_type_str</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class TextStringEncoder(encoding.TextStringEncoder):
    @classmethod
    def validate_value(cls, value):
        if is_bytes(value):
            try:
                value = to_text(value)
            except UnicodeDecodeError:
                cls.invalidate_value(
                    value,
                    msg=&#39;not decodable as unicode string&#39;,
                )

        super().validate_value(value)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li>eth_abi.encoding.TextStringEncoder</li>
<li>eth_abi.encoding.BaseEncoder</li>
<li>eth_abi.base.BaseCoder</li>
</ul>
<h3>Static methods</h3>
<dl>
<dt id="tronpytool.common.abi.TextStringEncoder.validate_value"><code class="name flex">
<span>def <span class="ident">validate_value</span></span>(<span>value)</span>
</code></dt>
<dd>
<div class="desc"><p>Checks whether or not the given value can be encoded by this encoder.
If the given value cannot be encoded, must raise
:any:<code>exceptions.EncodingError</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def validate_value(cls, value):
    if is_bytes(value):
        try:
            value = to_text(value)
        except UnicodeDecodeError:
            cls.invalidate_value(
                value,
                msg=&#39;not decodable as unicode string&#39;,
            )

    super().validate_value(value)</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.common.abi.TronAddressDecoder"><code class="flex name class">
<span>class <span class="ident">TronAddressDecoder</span></span>
<span>(</span><span>**kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Base class for all decoder classes.
Subclass this if you want to define a
custom decoder class.
Subclasses must also implement
:any:<code>BaseCoder.from_type_str</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class TronAddressDecoder(Fixed32ByteSizeDecoder):
    value_bit_size = 20 * 8
    is_big_endian = True
    decoder_fn = staticmethod(to_base58check_address)

    @parse_type_str(&#34;address&#34;)
    def from_type_str(cls, abi_type, registry):
        return cls()</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li>eth_abi.decoding.Fixed32ByteSizeDecoder</li>
<li>eth_abi.decoding.FixedByteSizeDecoder</li>
<li>eth_abi.decoding.SingleDecoder</li>
<li>eth_abi.decoding.BaseDecoder</li>
<li>eth_abi.base.BaseCoder</li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="tronpytool.common.abi.TronAddressDecoder.is_big_endian"><code class="name">var <span class="ident">is_big_endian</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.common.abi.TronAddressDecoder.value_bit_size"><code class="name">var <span class="ident">value_bit_size</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="tronpytool.common.abi.TronAddressDecoder.decoder_fn"><code class="name flex">
<span>def <span class="ident">decoder_fn</span></span>(<span>raw_addr: Union[str, bytes]) ‑> str</span>
</code></dt>
<dd>
<div class="desc"><p>Convert hex address or base58check address to base58check address(and verify it).</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_base58check_address(raw_addr: Union[str, bytes]) -&gt; str:
    &#34;&#34;&#34;Convert hex address or base58check address to base58check address(and verify it).&#34;&#34;&#34;
    if isinstance(raw_addr, (str,)):
        if raw_addr[0] == &#34;T&#34; and len(raw_addr) == 34:
            try:
                # assert checked
                base58.b58decode_check(raw_addr)
            except ValueError:
                raise BadAddress(&#34;bad base58check format&#34;)
            return raw_addr
        elif len(raw_addr) == 42:
            if raw_addr.startswith(&#34;0x&#34;):  # eth address format
                return base58.b58encode_check(b&#34;\x41&#34; + bytes.fromhex(raw_addr[2:])).decode()
            else:
                return base58.b58encode_check(bytes.fromhex(raw_addr)).decode()
        elif raw_addr.startswith(&#34;0x&#34;) and len(raw_addr) == 44:
            return base58.b58encode_check(bytes.fromhex(raw_addr[2:])).decode()
    elif isinstance(raw_addr, (bytes, bytearray)):
        if len(raw_addr) == 21 and int(raw_addr[0]) == 0x41:
            return base58.b58encode_check(raw_addr).decode()
        if len(raw_addr) == 20:  # eth address format
            return base58.b58encode_check(b&#34;\x41&#34; + raw_addr).decode()
        return to_base58check_address(raw_addr.decode())
    raise BadAddress(repr(raw_addr))</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.TronAddressDecoder.from_type_str"><code class="name flex">
<span>def <span class="ident">from_type_str</span></span>(<span>cls, abi_type, registry)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@parse_type_str(&#34;address&#34;)
def from_type_str(cls, abi_type, registry):
    return cls()</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.common.abi.TronAddressEncoder"><code class="flex name class">
<span>class <span class="ident">TronAddressEncoder</span></span>
<span>(</span><span>**kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Base class for all encoder classes.
Subclass this if you want to define a
custom encoder class.
Subclasses must also implement
:any:<code>BaseCoder.from_type_str</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class TronAddressEncoder(Fixed32ByteSizeEncoder):
    value_bit_size = 20 * 8
    encode_fn = staticmethod(to_tvm_address)
    is_big_endian = True

    @classmethod
    def validate_value(cls, value):
        if not is_address(value):
            cls.invalidate_value(value)

    def validate(self):
        super().validate()

        if self.value_bit_size != 20 * 8:
            raise ValueError(&#34;Addresses must be 160 bits in length&#34;)

    @parse_type_str(&#34;address&#34;)
    def from_type_str(cls, abi_type, registry):
        return cls()</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li>eth_abi.encoding.Fixed32ByteSizeEncoder</li>
<li>eth_abi.encoding.FixedSizeEncoder</li>
<li>eth_abi.encoding.BaseEncoder</li>
<li>eth_abi.base.BaseCoder</li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="tronpytool.common.abi.TronAddressEncoder.is_big_endian"><code class="name">var <span class="ident">is_big_endian</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.common.abi.TronAddressEncoder.value_bit_size"><code class="name">var <span class="ident">value_bit_size</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="tronpytool.common.abi.TronAddressEncoder.encode_fn"><code class="name flex">
<span>def <span class="ident">encode_fn</span></span>(<span>raw_addr: Union[str, bytes]) ‑> bytes</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_tvm_address(raw_addr: Union[str, bytes]) -&gt; bytes:
    return to_raw_address(raw_addr)[1:]</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.TronAddressEncoder.from_type_str"><code class="name flex">
<span>def <span class="ident">from_type_str</span></span>(<span>cls, abi_type, registry)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@parse_type_str(&#34;address&#34;)
def from_type_str(cls, abi_type, registry):
    return cls()</code></pre>
</details>
</dd>
<dt id="tronpytool.common.abi.TronAddressEncoder.validate_value"><code class="name flex">
<span>def <span class="ident">validate_value</span></span>(<span>value)</span>
</code></dt>
<dd>
<div class="desc"><p>Checks whether or not the given value can be encoded by this encoder.
If the given value cannot be encoded, must raise
:any:<code>exceptions.EncodingError</code>.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def validate_value(cls, value):
    if not is_address(value):
        cls.invalidate_value(value)</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="tronpytool.common.abi.TronAddressEncoder.validate"><code class="name flex">
<span>def <span class="ident">validate</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def validate(self):
    super().validate()

    if self.value_bit_size != 20 * 8:
        raise ValueError(&#34;Addresses must be 160 bits in length&#34;)</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="tronpytool.common" href="index.html">tronpytool.common</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="tronpytool.common.abi.abi_data_tree" href="#tronpytool.common.abi.abi_data_tree">abi_data_tree</a></code></li>
<li><code><a title="tronpytool.common.abi.abi_sub_tree" href="#tronpytool.common.abi.abi_sub_tree">abi_sub_tree</a></code></li>
<li><code><a title="tronpytool.common.abi.abi_to_signature" href="#tronpytool.common.abi.abi_to_signature">abi_to_signature</a></code></li>
<li><code><a title="tronpytool.common.abi.check_if_arguments_can_be_encoded" href="#tronpytool.common.abi.check_if_arguments_can_be_encoded">check_if_arguments_can_be_encoded</a></code></li>
<li><code><a title="tronpytool.common.abi.collapse_type" href="#tronpytool.common.abi.collapse_type">collapse_type</a></code></li>
<li><code><a title="tronpytool.common.abi.data_tree_map" href="#tronpytool.common.abi.data_tree_map">data_tree_map</a></code></li>
<li><code><a title="tronpytool.common.abi.fallback_func_abi_exists" href="#tronpytool.common.abi.fallback_func_abi_exists">fallback_func_abi_exists</a></code></li>
<li><code><a title="tronpytool.common.abi.filter_by_argument_count" href="#tronpytool.common.abi.filter_by_argument_count">filter_by_argument_count</a></code></li>
<li><code><a title="tronpytool.common.abi.filter_by_argument_name" href="#tronpytool.common.abi.filter_by_argument_name">filter_by_argument_name</a></code></li>
<li><code><a title="tronpytool.common.abi.filter_by_encodability" href="#tronpytool.common.abi.filter_by_encodability">filter_by_encodability</a></code></li>
<li><code><a title="tronpytool.common.abi.filter_by_name" href="#tronpytool.common.abi.filter_by_name">filter_by_name</a></code></li>
<li><code><a title="tronpytool.common.abi.filter_by_type" href="#tronpytool.common.abi.filter_by_type">filter_by_type</a></code></li>
<li><code><a title="tronpytool.common.abi.get_abi_input_names" href="#tronpytool.common.abi.get_abi_input_names">get_abi_input_names</a></code></li>
<li><code><a title="tronpytool.common.abi.get_abi_input_types" href="#tronpytool.common.abi.get_abi_input_types">get_abi_input_types</a></code></li>
<li><code><a title="tronpytool.common.abi.get_abi_output_types" href="#tronpytool.common.abi.get_abi_output_types">get_abi_output_types</a></code></li>
<li><code><a title="tronpytool.common.abi.get_constructor_abi" href="#tronpytool.common.abi.get_constructor_abi">get_constructor_abi</a></code></li>
<li><code><a title="tronpytool.common.abi.get_fallback_func_abi" href="#tronpytool.common.abi.get_fallback_func_abi">get_fallback_func_abi</a></code></li>
<li><code><a title="tronpytool.common.abi.is_address_type" href="#tronpytool.common.abi.is_address_type">is_address_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_array_type" href="#tronpytool.common.abi.is_array_type">is_array_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_bool_type" href="#tronpytool.common.abi.is_bool_type">is_bool_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_bytes_type" href="#tronpytool.common.abi.is_bytes_type">is_bytes_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_int_type" href="#tronpytool.common.abi.is_int_type">is_int_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_length" href="#tronpytool.common.abi.is_length">is_length</a></code></li>
<li><code><a title="tronpytool.common.abi.is_probably_enum" href="#tronpytool.common.abi.is_probably_enum">is_probably_enum</a></code></li>
<li><code><a title="tronpytool.common.abi.is_recognized_type" href="#tronpytool.common.abi.is_recognized_type">is_recognized_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_string_type" href="#tronpytool.common.abi.is_string_type">is_string_type</a></code></li>
<li><code><a title="tronpytool.common.abi.is_uint_type" href="#tronpytool.common.abi.is_uint_type">is_uint_type</a></code></li>
<li><code><a title="tronpytool.common.abi.length_of_array_type" href="#tronpytool.common.abi.length_of_array_type">length_of_array_type</a></code></li>
<li><code><a title="tronpytool.common.abi.map_abi_data" href="#tronpytool.common.abi.map_abi_data">map_abi_data</a></code></li>
<li><code><a title="tronpytool.common.abi.merge_args_and_kwargs" href="#tronpytool.common.abi.merge_args_and_kwargs">merge_args_and_kwargs</a></code></li>
<li><code><a title="tronpytool.common.abi.method_result_handler" href="#tronpytool.common.abi.method_result_handler">method_result_handler</a></code></li>
<li><code><a title="tronpytool.common.abi.normalize_event_input_types" href="#tronpytool.common.abi.normalize_event_input_types">normalize_event_input_types</a></code></li>
<li><code><a title="tronpytool.common.abi.process_type" href="#tronpytool.common.abi.process_type">process_type</a></code></li>
<li><code><a title="tronpytool.common.abi.size_of_type" href="#tronpytool.common.abi.size_of_type">size_of_type</a></code></li>
<li><code><a title="tronpytool.common.abi.strip_abi_type" href="#tronpytool.common.abi.strip_abi_type">strip_abi_type</a></code></li>
<li><code><a title="tronpytool.common.abi.sub_type_of_array_type" href="#tronpytool.common.abi.sub_type_of_array_type">sub_type_of_array_type</a></code></li>
<li><code><a title="tronpytool.common.abi.tron_patch_ethereum_types" href="#tronpytool.common.abi.tron_patch_ethereum_types">tron_patch_ethereum_types</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="tronpytool.common.abi.ABITypedData" href="#tronpytool.common.abi.ABITypedData">ABITypedData</a></code></h4>
</li>
<li>
<h4><code><a title="tronpytool.common.abi.AcceptsHexStrMixin" href="#tronpytool.common.abi.AcceptsHexStrMixin">AcceptsHexStrMixin</a></code></h4>
<ul class="">
<li><code><a title="tronpytool.common.abi.AcceptsHexStrMixin.validate_value" href="#tronpytool.common.abi.AcceptsHexStrMixin.validate_value">validate_value</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.common.abi.ByteStringEncoder" href="#tronpytool.common.abi.ByteStringEncoder">ByteStringEncoder</a></code></h4>
</li>
<li>
<h4><code><a title="tronpytool.common.abi.BytesEncoder" href="#tronpytool.common.abi.BytesEncoder">BytesEncoder</a></code></h4>
</li>
<li>
<h4><code><a title="tronpytool.common.abi.TextStringEncoder" href="#tronpytool.common.abi.TextStringEncoder">TextStringEncoder</a></code></h4>
<ul class="">
<li><code><a title="tronpytool.common.abi.TextStringEncoder.validate_value" href="#tronpytool.common.abi.TextStringEncoder.validate_value">validate_value</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.common.abi.TronAddressDecoder" href="#tronpytool.common.abi.TronAddressDecoder">TronAddressDecoder</a></code></h4>
<ul class="">
<li><code><a title="tronpytool.common.abi.TronAddressDecoder.decoder_fn" href="#tronpytool.common.abi.TronAddressDecoder.decoder_fn">decoder_fn</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressDecoder.from_type_str" href="#tronpytool.common.abi.TronAddressDecoder.from_type_str">from_type_str</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressDecoder.is_big_endian" href="#tronpytool.common.abi.TronAddressDecoder.is_big_endian">is_big_endian</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressDecoder.value_bit_size" href="#tronpytool.common.abi.TronAddressDecoder.value_bit_size">value_bit_size</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.common.abi.TronAddressEncoder" href="#tronpytool.common.abi.TronAddressEncoder">TronAddressEncoder</a></code></h4>
<ul class="two-column">
<li><code><a title="tronpytool.common.abi.TronAddressEncoder.encode_fn" href="#tronpytool.common.abi.TronAddressEncoder.encode_fn">encode_fn</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressEncoder.from_type_str" href="#tronpytool.common.abi.TronAddressEncoder.from_type_str">from_type_str</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressEncoder.is_big_endian" href="#tronpytool.common.abi.TronAddressEncoder.is_big_endian">is_big_endian</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressEncoder.validate" href="#tronpytool.common.abi.TronAddressEncoder.validate">validate</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressEncoder.validate_value" href="#tronpytool.common.abi.TronAddressEncoder.validate_value">validate_value</a></code></li>
<li><code><a title="tronpytool.common.abi.TronAddressEncoder.value_bit_size" href="#tronpytool.common.abi.TronAddressEncoder.value_bit_size">value_bit_size</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.1</a>.</p>
</footer>
</body>
</html>